package dmxGroupControl;

import org.jetbrains.annotations.NotNull;

public class Channel implements Comparable<Channel>
{
	private String name;
	private float value;
	private int min;
	private int max;
	private int channel;
	
	public Channel(String name, int min, int max, int channel)
	{
		this.name = name;
		this.min = min;
		this.max = max;
		this.channel = channel;
        this.value = 0.0f;
    }
	
	public String GetName()
	{
		return name;
	}
	
	public void SetValue(float value)
	{
		this.value = value;
	}
	
	public float GetValue()
	{
		return value;
	}
	
	public int GetDMXValue()
	{
		return Math.round(value * (max-min) + min);
	}
	
	public int GetDMXChannel()
	{
		return channel;
	}
	
	public int GetMin()
	{
	    return min;
	}
	
	public int GetMax()
	{
	    return max;
	}

	@Override
    public int compareTo(@NotNull Channel other)
	{
		if(this.channel != other.channel)
		{
			Integer thisInt = this.channel;
			Integer otherInt = other.channel;
			return thisInt.compareTo(otherInt);
		}
		else
		{
			Integer thisMin = this.min;
			Integer otherMin = other.min;
			return thisMin.compareTo(otherMin);
		}
	}

	public void SetName(String value)
	{
		this.name = value;
	}

	public void SetMax(int value)
	{
		this.max = value;
	}

	public void SetMin(int value)
	{
		this.min = value;
	}

	public void SetDMXChannel(int value)
	{
		this.channel = value;
	}
	
	@Override
	public String toString()
	{
        return GetName();
    }
}
